/*************************************************************************
    > File Name: test.c
	> company: GDOU
    > Mail: lsy476941913@live.com 
    > Created Time: 2017年02月23日 星期四 20时36分17秒
 ************************************************************************/
#include <string.h>
#include "argopt.h"
#include "mp3_play.h"

extern char *vol;
int argopt(int argc,char **argv,char *optstring)
{
	vol=(char *)malloc(sizeof(char)*50);
	memset(vol,0,50);
	char *path;
	path=(char *)malloc(sizeof(char)*256);
	if(argc<2)
	{
		strcpy(vol," ");
		return 0;
	}

	//	showinfo(path);
	int oc;
	//char *cmdopt;
	while((oc=getopt(argc,argv,optstring))!=-1)
	{

		switch(oc)
		{
			case 'a':
				if(argv[2] != NULL){
					strcpy(vol," -A +");
					strcat(vol,argv[2]);
					printf("add vol\n");
				}
				else{
					strcpy(vol," -A +");
					strcat(vol,"0");
					printf("add vol\n");
				}
				break;
			case 's':
				if(argv[2] != NULL){
					strcpy(vol," -A -");
					strcat(vol,argv[2]);
					printf("sub vol\n");
				}
				else{
					strcpy(vol," -A -");
					strcat(vol,"0");
					printf("sub vol\n");
				}
				break;
;
			case '?':
				{
					printf("arg error : piano -[al] <add num><sub num>\n");
					printf("-a [add num]: add vol\n");
					printf("-s [sub num]: sub vol\n");
					free(path);
					exit(EXIT_FAILURE);
				}
		}
	}
	return 0;
}


